|
|
|
|
|
|
|
Graph1.AutoInc = 1 ' turn on auto incrementing
For intLoop = 1 To 12
Graph1.GraphData = intLoop ' data to load
Next
'
Graph1.DrawMode = gphDraw ' show results
'
End Sub |
|
|
|
|
|
|
|
|
Save and run the project. When you press the AutoSales button, you see the same graph that was generated with the Sales button. Notice that, in this example, you left out the lines of code that set the ThisSet and ThisPoint properties. These values were handled by the graph control using the AutoInc property. This might not seem like a code savings, but it really is. Single-set data is relatively easy to graph. Multiple sets get pretty confusing. It's much easier to use the AutoInc property because it automatically updates the ThisSet property, too. Not only is this approach a bit easier, it is also faster. The fewer lines of code you need to execute within the For...Next loop, the faster your program runs. |
|
|
|
|
|
|
|
|
There is yet another way to add data to a graph control: by using the QuickData property. |
|
|
|
|
|
|
|
|
Adding Data Using the QuickData Property |
|
|
|
|
|
|
|
|
You can use the QuickData property to add graph data in a single command at runtime. The QuickData property accepts a single character string that contains all the datasets and points. Each dataset must be separated by a carriage return/line feed pair. Each data point must be separated by a tab character. This is known as tab-delimited data. When you use the QuickData property to load graph data, you do not have to set any of the properties that deal with points or sets. You also do not have to force your Visual Basic code to process any For...Next loops. |
|
|
|
|
|
|
|
|
Add another command button to the form, setting its Name property to cmdQuickSales and its Caption property to &QuickSales. Then add the code in Listing 11.3 in the cmdQuickSales_Click event window. |
|
|
|
|
| |
|
|
|
|
If you're using "code-complete," you notice that the QuickData property is missing from the list of valid selections in the pop-up window. Don't let Visual Basic 5 fool you! The QuickData property is a valid property for the GRAPH32.OCX control. It's just missing from the list. |
|
|
|
|
|
|
|